
<table width="100%" rules="all" border="1" cellpadding="0" class="tblSort" id="tbl_qcli" cellspacing="0" >
<thead>
<tr>
<th>ID Cliente</th>
<th>Nombres/Raz.Social</th>
<th>Nombres 2</th>
<th>Direccion</th>
<th>Nro.Ident.Fiscal</th>
<th>Nom.Contacto</th>
<th>Creador por</th>
</tr>
</thead>
<tbody>
<?php
 include('../../Connections/KRAPPERCON.php');
$oper = $_POST['oper'];

$noms = $_POST['t_lc_noms'];
$apat = $_POST['t_lc_apat'];
$amat = $_POST['t_lc_amat'];
$dir = $_POST['t_lc_dir'];
$nif = $_POST['t_lc_nif'];
$con = $_POST['t_lc_con'];

$str_noms = isNull($noms,"and ClientNom like '%".$noms."%'");
$str_apat = isNull($apat,"and ClientApePat like '%".$apat."%'");
$str_amat = isNull($amat,"and ClientApePat like '%".$amat."%'");

$str_dir = isNull($dir,"and ClientDir like '%".$dir."%'");
$str_nif = isNull($nif,"and ClientNif like '%".$nif."%'");

$str_con = isNull($con,"and ClientContac like '%".$con."%'");

$where = $str_noms.$str_apat.$str_amat.$str_dir.$str_nif.$str_con;
	if (trim($where)!= '' ){
		$where = 'where '.substr(ltrim($where),3);
	}



$sql = "SELECT
ClientID,
ClientNom,
ClientApePat,
ClientApeMat,
ClientDirec,
ClientSts,
ClientNIF,
UbigeoID,
ClientDirec2,
ClientCel,
ClientTelf,
ClientMail,
ClientContac,
CliTypeID,
CliZoneID,
UserID,
ClientSort1
FROM vt_cliente ".$where." order by ClientID";
doEcho($sql);
//doEcho($sql);
$a1 = '';
$a2 = '';
$sub = '';
if (isset($_POST['finder'])){
	$sub = getVal('finder');
	if (trim($sub)!="") {
	$a2 = '</a>';
	$a1 = '<a href="#" class="a" onclick="selCliPed(this)">';
	}
	else {
	$a2 = '</a>';
	$a1 = '<a href="#" class="a">';
	}
}

$res = $mysqli->query($sql);
if ($res){
	while($row = $res->fetch_assoc()){
	echo "<tr>
	<td>".$a1.$row['ClientID'].$a2."</td>
    <td class='b'>".$row['ClientNom']."</td>
	<td class='c'>".$row['ClientApePat']."&nbsp;".$row['ClientApeMat']."</td>
	<td class='d'>".$row['ClientDirec']."</td>
	<td class='e'>".$row['ClientNIF']."</td>  
	<td>".$row['ClientContac']."</td>
	<td>".$row['UserID']."</td>
	</tr>";
	}
$res->close();
$mysqli->check_result();
}
/*
t_lc_noms : GEBI('t_lc_noms').value,
		t_lc_apat : GEBI('t_lc_apat').value,
		t_lc_amat : GEBI('t_lc_amat').value,
		t_lc_dir : GEBI('t_lc_dir').value,
		t_lc_nif : GEBI('t_lc_nif').value,
		t_lc_dir : GEBI('t_lc_dir').value,
		t_lc_con : GEBI('t_lc_con').value
*/
?>
</tbody>
</table>
<script type="text/javascript">
	function selCliPed(obj){
	<?php if (trim($sub)!="") { ?>
		var fila = $(obj).parent().parent();
		var obj = {cod:fila.find('.a').html(),
						nom:fila.find('.b').text(),
						ape:fila.find('.c').text(),
						dir:fila.find('.d').text(),
						nif:fila.find('.e').text()};						
		<?php 
		echo $sub.'(obj);';
		?>
		closePopup();
		<?php if (getVal('noClose')=='') echo "closePopup();"; ?>
		
		<?php } ?>
	}
	
	<?php 
	if (trim($sub)=="") {
	?>
	$("#tbl_qcli tbody .a").each(function(){
		this.href = '#page/Mantenimientos/MantCli.php?codcli='+this.innerHTML;
	});
	<?php 
	}
	?>
</script>